import Vue from "vue"
import Router from 'vue-router'
import createRouter from '@/router/router'
import App from "./App.vue"
import Cloudbase from "@cloudbase/vue-provider"

import './assets/styles/global.css'
import './assets/styles/base.css'
import './assets/styles/reset2.css'

import { ENV_ID } from '~utils/envId'
import { getOpenid, showWarningToast } from '~utils'
// import Vant from 'vant';
// import 'vant/lib/index.css';

// 注意更新此处的TCB_ENV_ID为你自己的环境ID
window._tcbEnv = window._tcbEnv || { TCB_ENV_ID: ENV_ID }

export const envId = window._tcbEnv.TCB_ENV_ID
export const region = window._tcbEnv.TCB_REGION

Vue.config.productionTip = false

Vue.use(Cloudbase, {
  env: envId,
  region: region
})

Vue.use(Router)

let router = createRouter()

let openid = getOpenid() // 获取openid
localStorage.setItem('openid', openid)
Vue.prototype.$openid = openid

if (!openid) {
  showWarningToast('缺少id参数')
}

let app = new Vue({
  router: router,
  render: h => h(App)
}).$mount("#app")

export function getApp () {
  return { app, router }
}